<!--
 * @Author: wangjh wangjiahui0710@163.com
 * @Date: 2024-06-18 10:06:26
 * @LastEditors: wangjh wangjiahui0710@163.com
 * @LastEditTime: 2024-06-19 09:33:06
 * @FilePath: \cip-admin\src\pages\company\information.page.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 信息录入 layout -->
<script lang="ts" setup>
import { computedLoading } from "@/hooks/computed-loading";
import { useUserStore } from "@/stores/user";

const userStore = useUserStore();

definePage({
	meta: { title: "企业信息维护", order: 2 },
});
defineOptions({ name: "InformationPage" });

const components = [
	{
		name: "基本信息",
		component: () => import("./information/basic/index.vue"),
	},
	{
		name: "人员信息",
		component: () => import("./information/person/index.vue"),
	},
	{
		name: "设备信息",
		component: () => import("./information/equipment/index.vue"),
	},
	{
		name: "两重点一重大",
		component: () => import("./information/point-major/index.vue"),
	},
	{
		name: "消防设施台账",
		component: () => import("./information/fire-fighting/index.vue"),
	},
	{
		name: "事故事件管理",
		component: () => import("./information/accident/index.vue"),
	},
	{
		name: "安全与环境管理信息",
		component: () => import("./information/safety-environment/index.vue"),
	},
	{
		name: "第三方单位",
		component: () => import("./information/third-party-company/index.vue"),
	},
	{
		name: "评价评估报告",
		component: () => import("./information/evaluation/index.vue"),
	},
];

if (userStore.userType !== "1") {
	components.push({
		name: "企业安全承诺",
		component: () => import("./information/security-promise/index.vue"),
	});
}

const activeIndex = ref(components[0].name);

const [activeComponent, componentLoading] = computedLoading(async () => {
	const m = await components
		.find((e) => e.name === activeIndex.value)
		?.component();
	return m?.default;
});
</script>

<template>
	<page-content>
		<template #header>
			<el-menu
				:default-active="activeIndex"
				mode="horizontal"
				w="100%"
				@select="(index) => (activeIndex = index)"
			>
				<el-menu-item
					v-for="item in components"
					:key="item.name"
					:index="item.name"
				>
					{{ item.name }}
				</el-menu-item>
			</el-menu>
		</template>
		<div v-loading="componentLoading" flex="~ col 1" of="hidden">
			<component :is="activeComponent" />
		</div>
	</page-content>
</template>
